package com.fjnu.entities;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.*;
import javax.persistence.ManyToMany;
import javax.persistence.Transient;

import com.fasterxml.jackson.annotation.JsonIdentityInfo;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.ObjectIdGenerators;

/**
 * User entity. @author MyEclipse Persistence Tools
 */
@JsonIgnoreProperties(value={"hibernateLazyInitializer","handler","fieldHandler"})
@JsonIdentityInfo(
        generator = ObjectIdGenerators.PropertyGenerator.class,
        property = "id",
        scope = User.class)
public class User implements java.io.Serializable {

	// Fields

	private Integer id;
	private String name;
	private String idnumber;
	private String password;
	private String phone;
	private String qq;
	private String sex;
	private Set<Role> roleList;
	private Set<BaseRepair> baseRepair;
	private Set<ExamRepair> examRepair;
	private Set<FinalRepair> finalRepair;
	private Set<MainInstrument> mainInstruments;
	private Set<EnclosureInstrument> enclosureInstruments;
	private Set<Borrow> borrow;
	private Unit unit;
	
	private Set<Borrow> examBorrow;
	// Constructors

	/** default constructor */
	public User() {
	}

	/** full constructor */
	public User(String name, String idnumber, String password,String phone, String qq,
			String sex,Set<Role> roleList,Unit unit) {
		this.name = name;
		this.idnumber=idnumber;
		this.password =password;
		this.phone = phone;
		this.qq = qq;
		this.sex = sex;
		this.roleList= roleList;
		this.unit=unit;
	}

	// Property accessors

	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}


	public String getPhone() {
		return this.phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getQq() {
		return this.qq;
	}

	public void setQq(String qq) {
		this.qq = qq;
	}

	public String getSex() {
		return this.sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getIdnumber() {
		return idnumber;
	}

	public void setIdnumber(String idnumber) {
		this.idnumber = idnumber;
	}
    public Set<Role> getRoleList() {
        return roleList;
    }

    public void setRoleList(Set<Role> roleList) {
        this.roleList = roleList;
    }

    @Transient
    public Set<String> getRolesName() {
        Set<Role> roles = getRoleList();
        Set<String> set = new HashSet<String>();
        for (Role role : roles) {
            set.add(role.getRolename());
        }
        return set;
    }

	public Set<BaseRepair> getBaseRepair() {
		return baseRepair;
	}

	public void setBaseRepair(Set<BaseRepair> baseRepair) {
		this.baseRepair = baseRepair;
	}

	public Set<ExamRepair> getExamRepair() {
		return examRepair;
	}

	public void setExamRepair(Set<ExamRepair> examRepair) {
		this.examRepair = examRepair;
	}

	public Set<FinalRepair> getFinalRepair() {
		return finalRepair;
	}

	public void setFinalRepair(Set<FinalRepair> finalRepair) {
		this.finalRepair = finalRepair;
	}

	public Set<MainInstrument> getMainInstruments() {
		return mainInstruments;
	}

	public void setMainInstruments(Set<MainInstrument> mainInstruments) {
		this.mainInstruments = mainInstruments;
	}

	public Set<EnclosureInstrument> getEnclosureInstruments() {
		return enclosureInstruments;
	}

	public void setEnclosureInstruments(Set<EnclosureInstrument> enclosureInstruments) {
		this.enclosureInstruments = enclosureInstruments;
	}

	public Set<Borrow> getBorrow() {
		return borrow;
	}

	public void setBorrow(Set<Borrow> borrow) {
		this.borrow = borrow;
	}

	public Set<Borrow> getExamBorrow() {
		return examBorrow;
	}

	public void setExamBorrow(Set<Borrow> examBorrow) {
		this.examBorrow = examBorrow;
	}

	public Unit getUnit() {
		return unit;
	}

	public void setUnit(Unit unit) {
		this.unit = unit;
	}

}